package org.jpush.core;

import org.jpush.packages.IncomingPacket;

/**
 * A <code>Service</code> is used to process a request
 * from a connection. You should implement the method
 * @see handle to implement your own service
 * 
 * @author Lei Wang
 *
 */
public abstract class Service
{
	protected Server server;
	private String name;
	public Service(Server server)
	{
		this(server, "");
	}

	public Service(Server server, String name)
	{
		this.server = server;
		this.name = name;
	}
	
	public Server getServer()
	{
		return this.server;
	}
	
	public void setServer(Server server)
	{
		this.server = server;
	}
	
	public String getName() {
		return this.name;
	}
	
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * To process the incoming request from a connection
	 * 
	 * @param connection   The logic connection object
	 * @param request      The packet of the request
	 */
	public abstract void handle(LogicalConnection connection, IncomingPacket request);
}
